<template>
    <div>
        <h1>接口平台首页</h1>
        {{ $store.state.user }}
        <button @click="handleLogout">退出登录</button>
    </div>

</template>

<script setup lang="ts" name="Index">
import { useCookies } from '@vueuse/integrations/useCookies'
import { getToken, removeToken } from '@/composables/auth'
import { showModel, toast } from '@/composables/util'
import { logout_func } from '@/api/manager'
import { useRouter } from 'vue-router'
import { useStore } from 'vuex'
const router = useRouter()
const store = useStore()

function handleLogout() {
    showModel("是否要推出登录").then(res => {
        logout_func().finally(() => {
            store.dispatch('logout')
            // 清除当前用户状态：vuex中的state.user
            router.push('/login')
            toast("退出登录成功", "成功")
        })
    })
}
</script>

<style scoped></style>